/*************************************************************
 * File: Validator.java
 * Author: Huang Shaobin
 * Email: Shaobin.Software@gmail.com Shaobin_Software@163.com 
 * Date: Jan 31, 2013 6:22:45 AM
 * Description: 
 * Copyright (c) 2012
 ************************************************************/
package snow.core.toolkit;

import org.apache.commons.lang.StringUtils;

import snow.core.exception.BusinessException;

/**
 *
 */
public class Validator {

	public static void hasText(String text, String code, String message) throws BusinessException {
		if (StringUtils.isBlank(text)) {
			throw new BusinessException(code, message);
		}
	}

	public static void isTrue(boolean expression, String code, String message) throws BusinessException {
		if (!expression) {
			throw new BusinessException(code, message);
		}
	}

	public static void notNull(Object object, String code, String message) throws BusinessException {
		if (object == null) {
			throw new BusinessException(code, message);
		}
	}

}
